package demo014;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class User1 {
    @Autowired //类型注入
    @Qualifier(value = "cat")  //名称注入
    private Rabbit rabbit;
    public void say(){
        rabbit.hello();
    }

}

@Component
class User2{
    @Autowired
    @Qualifier(value = "dog1")
    private Rabbit rabbit;
    public void set(){
        rabbit.hello();
    }
}